﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;

namespace Business.Crypto
{
    public static class HashKeyAlg
    {
        private const string KEY_SALT = "this is my salt !";

        public static string GetHash(string password, string text)
        {
            Rfc2898DeriveBytes myKey = new Rfc2898DeriveBytes(password, Encoding.Unicode.GetBytes(KEY_SALT));

            byte[] secretkey = myKey.GetBytes(16);
            byte[] textByte = Encoding.Unicode.GetBytes(text);

            HMACSHA1 myAlg = new HMACSHA1(secretkey);
            myAlg.ComputeHash(textByte);

            return Convert.ToBase64String(myAlg.Hash);

        }
    }
}
